#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:3_do_encrypt_password.py
# author:张世航
# datetime:2024/11/9 22:29
# software: PyCharm
"""
this is function  description 
"""
# import module your need


# 3  从键盘输入5个同学的账号和密码,然后将他们的姓名,账号和密码(密码需要加密)保存到一个文件中;
#         Tom   admin   XXXXX
#         Jack   root      XXXXX
import hashlib

def encrypt_password(password):
    """简单的密码加密"""
    return hashlib.sha256(password.encode()).hexdigest()

students = []
for _ in range(5):
    name = input("请输入姓名: ")
    account = input("请输入账号: ")
    password = input("请输入密码: ")
    encrypted_password = encrypt_password(password)
    students.append((name, account, encrypted_password))

# 保存到文件
with open("students.txt", "w", encoding="utf-8") as f:
    for student in students:
        f.write(f"{student[0]} {student[1]} {student[2]}\n")